# -*- coding:utf-8 -*-

import time
def dict2Sheet(d):
	return Sheet(d['createuser'],d['title'],d['sheetType'],d['sheetid'],d['nexturl'])
	
class Sheet(object):
	def __init__(self, createuser, title, sheetType, sheetid, nexturl, processedFlag=False):
		self.id = None
		self.createuser = createuser
		self.title = title
		self.sheetType = sheetType
		self.sheetid = sheetid
		self.nexturl = nexturl
		params = nexturl.split('&')
		self.urlName = params[2].replace('urlName=','')
		self.sheetId2 = params[3].replace('sheetId=','')
		self.sheetType2 = params[4].replace('sheetType=', '')
		self.processDefName = params[5].replace('processDefName=','')
		self.baseSheetId = params[6].replace('baseSheetId=', '')
		self.activeDefId = params[7].replace('activeDefId=', '')
		self.activeInsId = params[8].replace('activeInsId=', '')
		self.workItemId = params[9].replace('workItemId=', '')
		self.workItemState = params[10].replace('workItemState=', '')
		self.processInsId = params[11].replace('processInsId=', '')
		self.processedFlag = processedFlag
		self.username = None
		self.reason = ''
		self.sheetTime = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))
		
	def __str__(self):
		return 'url:%s' % self.nexturl
		
class User(object):
	def __init__(self, name,email):
		self.id = None
		self.name = name
		self.email = email
	def __str__(self):
		return self.name
		
class Mail(object):
	def __init__(self,receiver,sub,content,sendFlag=False):
		self.id = None
		self.receiver = receiver
		self.sub = sub
		self.content = content
		self.sendFlag = sendFlag
	
	def __str__(self):
		return '%s,%s,%s' % (self.sub,self.content,self.receiver)